feat(mesh): add session singleton and peer registry#101
Open
cagataycali wants to merge 3 commits intostrands-labs:mainfrom
Open
feat(mesh): add session singleton and peer registry#101cagataycali wants to merge 3 commits intostrands-labs:mainfrom
cagataycali wants to merge 3 commits intostrands-labs:mainfrom
Conversation
This was referenced Apr 21, 2026
Member
Author
45 tasks
Add strands_robots/mesh_session.py — the foundation layer for Zenoh mesh networking. This is PR 1 of 6 in the mesh implementation plan (issue cagataycali/strands-gtc-nvidia#313). Session lifecycle: - get_session() / release_session(): lazy, ref-counted zenoh.Session - First process listens on tcp/127.0.0.1:7447; second falls back to client - atexit handler prevents session leaks on process exit - Configurable via ZENOH_CONNECT, ZENOH_LISTEN, STRANDS_MESH_PORT env vars Peer registry: - PeerInfo dataclass with age tracking and serialisation - Thread-safe upsert (update_peer), pruning (prune_peers), query (get_peers) - Shared across all Mesh instances in a process Publish helper: - put(key, data): fire-and-forget JSON publish, no-op when session is None Dependency: - New [mesh] optional extra: eclipse-zenoh>=1.0.0,<2.0.0 - zenoh.* added to mypy ignore_missing_imports - Zero zenoh import at module level (lazy inside get_session) Tests: 29 tests, all mocked (no network required), 90% coverage on module
mypy requires generator functions (those using yield) to declare a Generator/Iterator return type instead of None. Changed all 4 pytest fixtures from -> None to -> Iterator[None] and removed the now- unnecessary # type: ignore[misc] comments. Fixes: 4 mypy [misc] errors on lines 78, 168, 315, 414
5cb85d5 to
50b5d03
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
strands_robots/mesh_session.py— the foundation layer for Zenoh mesh networking. This is PR 1 of 6 in the mesh implementation plan.What this PR adds
Session lifecycle (
get_session/release_session):zenoh.Session— one per processtcp/127.0.0.1:7447; subsequent processes fall back to client modeatexithandler prevents session leaksZENOH_CONNECT,ZENOH_LISTEN,STRANDS_MESH_PORTenv varsPeer registry (thread-safe, shared across all Mesh instances):
PeerInfodataclass with age tracking and JSON serialisationupdate_peer()/prune_peers()/get_peers()/get_peer()Publish helper:
put(key, data)— fire-and-forget JSON publish, safe no-op when session isNoneDependency:
[mesh]optional extra:eclipse-zenoh>=1.0.0,<2.0.0zenoh.*added to mypyignore_missing_importsget_session)6-PR Roadmap
Testing
mesh_session.pyFiles changed
strands_robots/mesh_session.pytests/mesh/__init__.pytests/mesh/test_mesh_session.pypyproject.toml[mesh]extra, zenoh mypy override🤖 AI agent response. Strands Agents. Feedback welcome!